package com.itheima.health.controller;

import com.itheima.health.dto.SetmealDTO;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.service.OrderSettingService;
import com.itheima.health.service.SetmealService;
import com.itheima.health.utils.aliyunoss.AliyunUtils;
import com.itheima.health.utils.poi.POIUtils;
import com.itheima.health.utils.redis.RedisUtil;
import com.itheima.health.utils.resources.RedisConstant;
import com.itheima.health.utils.resources.UploadUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;

//  ordersetting/importOrderSettings
@RestController
@RequestMapping("ordersetting")
@Api(tags = "传智健康预约模块之套餐管理")
public class OrderSettingController {

    @Reference
    private OrderSettingService orderSettingService;





    @PostMapping("importOrderSettings")
    public Result   importOrderSettings(@RequestParam("excelFile")MultipartFile file){
        System.out.println(file.getOriginalFilename()+"--------");
        //  String[]   row      String[0]  第一列值     String[1]  第二列值
        List<String[]> readExcel = POIUtils.readExcel(file);
        return  new Result(orderSettingService.importOrderSettings(readExcel));
    }

    @GetMapping("findSettingData/{year}/{month}")
    public Result   findSettingData(@PathVariable("year")int year,@PathVariable("month") int month){
        return  new Result(orderSettingService.findSettingData(year,month));
    }

    @PutMapping("updateNumberByOrderDate/{number}/{orderdate}")
    public Result   updateNumberByOrderDate(@PathVariable("number")int number,@PathVariable("orderdate") String orderdate){
        orderSettingService.updateNumberByOrderDate(number,orderdate);
        return  new Result(true);
    }








}
